import sys
import pygame

#initialize pygame module and clock
pygame.init()
clock = pygame.time.Clock()

#set size of the screen we want to display
size = width,height = 640, 480

#define the screen
screen = pygame.display.set_mode(size)

#get a local image
localImage = pygame.image.load("cat.jpg")

#get rectangular coordinates of image and store in a pygame Rect Object
#the rectangular coordinates will be used to paint to the surface
catRect = localImage.get_rect()

#define speed in x,y coord
speed = [0,0]
#represents arrows in the follwoing order : Left, Right, Up, Down
speedInput = [0,0,0,0]
#draw the screen
while 1:
    clock.tick(60)
    #Fill the Canvas only once
    screen.fill(000000)
    for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()
        if event.type== pygame.KEYUP:
            if event.key == 273:
                speedInput[2]=0
            if event.key == 274:
                speedInput[3]=0
            if event.key == 275:
                speedInput[1]=0
            if event.key == 276:
                speedInput[0]=0
        if event.type== pygame.KEYDOWN:
            if event.key == 273:
                speedInput[2]=-1
            elif event.key == 274:
                speedInput[3]=1
            elif event.key == 275:
                speedInput[1]=1
            elif event.key == 276:
                speedInput[0]=-1
        print(event)
        speed[0]=speedInput[0]+speedInput[1]
        speed[1]=speedInput[2]+speedInput[3]
    catRect.move_ip(speed)
    #print(speed)

 
    #pyDrawLines.DrawLine(screen)
    screen.blit(localImage, catRect)
    pygame.display.flip()